package com.xwn.customer.controller;

import com.xwn.api.service.IHelloApi;
import com.xwn.bean.system.ResponseBodyEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 测试controller
 * @Author duandw
 * @Date 2019/10/24 17:09
 **/
@RequestMapping("ceshi")
@RestController
@Slf4j
public class HelloController{

    /**
     *  通过xml配置文件暴露接口时,接口的调用使用@Autowired注解,不用@Reference,相当于通过spring将这个接口对象注入了
     */
    @Autowired
    private IHelloApi helloService;

    /**
     * 对外接口
     * 说hello
     * @Param name 调用的用户
     * @return 返回统一格式
     **/
    @RequestMapping(value = "hello/${name}" ,method = RequestMethod.GET)
    public ResponseBodyEntity sayHello(@PathVariable String name){
        ResponseBodyEntity response = new ResponseBodyEntity();
        response.setCode(200);
        response.setData("测试");
        response.setMsg(helloService.sayHello(name));
        return response;
    }
}
